//用户详细信息
function userdetail(id,us){
	var url = "frontend/userdetail.asp?id="+id+"&us="+us+"&timestamp="+ new Date().getTime();
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleuserdetailStateChange;
    xmlHttp.open("get",url,true);
    xmlHttp.send(null);
}
//修改用户信息
function modiuser(id,us){
	var url = "frontend/modiuser.asp?id="+id+"&us="+us+"&timestamp="+ new Date().getTime();
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleuserdetailStateChange;
    xmlHttp.open("get",url,true);
    xmlHttp.send(null);
}
function handleuserdetailStateChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
		var ajaxRequestObj = xmlHttp.responseText;
		shadeandoperate(1);
		var no = document.getElementById(nowdiv+"_operate");
		no.style.overflowY="auto";
		no.style.width=document.getElementById(nowdiv).clientWidth;
		document.getElementById(nowdiv+"_operate").innerHTML = ajaxRequestObj;
		document.all.topoperation.innerHTML = "用户信息";
        }
    }
}
//执行修改动作
function edituser(id){
	var a = document.getElementById("editLP").value;
	var b = document.getElementById("editNM").value;
	var c = document.getElementById("editCD").value;
	var d = document.getElementById("editML").value;
	var e = document.getElementById("editUA").value;
	var f = document.getElementById("editPV").value;
	var g = document.getElementById("editPN").value;
	var h = document.getElementById("editCT").value;
	var i = document.getElementById("editFA").value;
	var j = document.getElementById("editDT").value;
	var k = document.getElementById("editPT").value;
	var l = document.getElementById("editRN").value;
	var m = document.getElementById("editMB").value;
	var n = document.getElementById("editIC").value;
	var o = document.getElementById("editTP").value;
	var p = document.getElementById("editDT2").value;
	var q = document.getElementById("editEM").value;
	var r = document.getElementById("editOL").value;
	var s = document.getElementById("editMQ").value;
	var t = document.getElementById("editRM").value;
	var poststring = "a="+a+"&b="+b+"&c="+c+"&d="+d+"&e="+e+"&f="+f+"&g="+g+"&h="+h+"&i="+i+"&j="+j+"&k="+k+"&l="+l+"&m="+m+"&n="+n+"&o="+o+"&p="+p+"&q="+q+"&r="+r+"&s="+s+"&t="+t;
	var url = "backend/edituser.asp?id="+id+"&timestamp="+ new Date().getTime();
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = userEditChange;
    xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    xmlHttp.send(poststring);
}

function userEditChange() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			var ajaxRequestObj = xmlHttp.responseText;
			userdetail(ajaxRequestObj);
			showmsg('a','修改操作最后结果','用户信息修改成功！');
			document.all.topoperation.innerHTML = "修改用户";
        }
    }
}

//移动用户位置
function moveuser(id,us){
	var url = "frontend/moveuser.asp?id="+id+"&us="+us+"&timestamp="+ new Date().getTime();
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChange1;
    xmlHttp.open("get",url,true);
    xmlHttp.send(null);
}
function submitmoveuser(id){
	var a = document.getElementById("fathernodeid").value;
	var url = "backend/moveuser.asp?id="+id+"&a="+a+"&timestamp="+ new Date().getTime();
	if (a==-1)
		alert("请选择实际的单位！");
	else{
		if (a<200)
			alert("无法移动到\"其他\"，请选择实际的单位！");
		else{
			createXMLHttpRequest();
			xmlHttp.onreadystatechange = moveuserStateChange;
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
		}
	}
}
function moveuserStateChange(){
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
			var ajaxRequestObj = xmlHttp.responseText;
			if (ajaxRequestObj=="same"){
				showmsg('a','移动用户操作最后结果','相同单位，没有移动！');
			}else{
				depid=ajaxRequestObj.split("|");
				depdetail(1,depid[1]);
				setTimeout("depdetail('1','"+depid[0]+"');",500);
				showmsg('a','移动用户操作最后结果','移动用户成功！');
			}
			document.all.topoperation.innerHTML = "移动用户";
        }
    }
}